package com.gongj.rabbitboot2.direct;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class directCustomer {

    @RabbitListener(bindings = {
            @QueueBinding(value = @Queue,  //创建临时队列
                    exchange = @Exchange(value = "direct-boot-exchange",type = "direct"),  //绑定交换机名称和类型，默认类型就为direct
                    key = {"info"})  //路由key

    })
    public void directStr(String message){
        System.out.println("消费消息-1：" + message);
    }

    @RabbitListener(bindings = {
            @QueueBinding(value = @Queue,
                    exchange = @Exchange(value = "direct-boot-exchange",type = "direct"),
            key={"info","error"})

    })
    public void directStr2(String message){
        System.out.println("消费消息-2：" + message);
    }
}
